proc test { } {
    set bname "var_"
    append bname [expr round(rand()*1000)]
    puts $bname
    button .$bname -text $bname
    pack .$bname
}

# after 2000 test
# after 4000 test

proc every {ms body} {
    eval $body
    after $ms [info level 0];	# the name of this proc (here is every)
}

# every 1000 {test}

set nmax 5
every 1000 {test; if {[incr ::nmax -1]<=0} return}

